package cur.nature.component.redis.controller;

import cur.nature.component.redis.common.RedisUtil;
import cur.nature.framework.core.log.LOG;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 缓存 Controller
 * 作者：Auto Generator By wujian
 * 生成日期：2023-08-05 17:57:55
 */
@Tag(name = "缓存 接口")
@RestController
@RequestMapping("component/redis/v1/api/cache")
@ConditionalOnProperty( value = {"cur.component.redis.controller.enable"})
public class Redis_CacheController {

    @Operation(summary = "设置 缓存")
    @GetMapping("/set")
    public void set() throws Exception {
        LOG.info("set redis");
        RedisUtil.set("test", "aaaaa");
    }

    @Operation(summary = "获取 缓存")
    @GetMapping("/get")
    public Map<String, String> get() throws Exception {
        LOG.info("get redis");
        Map<String, String> resMap = new HashMap<>();
        RedisUtil.set("test", "aaaaa");
        resMap.put("test", (String) RedisUtil.get("test"));
        return resMap;
    }

}

